package cc.bluemc.platform.annotation;

import cc.bluemc.platform.annotation.executerConfig.ExecuterConfig;
import cc.bluemc.platform.annotation.executerConfig.ExecuterConfigExecuter;

import java.lang.annotation.Annotation;


/**
 * 注解执行类
 * @author Administrator
 *
 */
public class AnnotationExecuter {

	@SuppressWarnings("unchecked")
	public static <T> T execute(Annotation annotation,T value){
		Class annClazz= annotation.annotationType();
		if(annotation instanceof ExecuterConfig){
			AnnotationExecuterInterface executer= new ExecuterConfigExecuter();
			return executer.execute(annotation, value);
		}else{
			ExecuterConfig annExeAnn = (ExecuterConfig) annClazz.getAnnotation(ExecuterConfig.class);
			if(null!=annExeAnn){
				AnnotationExecuterInterface executer= (AnnotationExecuterInterface) execute(annExeAnn,value);
				return executer.execute(annotation, value);
			}
			return null;
		}
	}
}
